import plotly.express as px
from pywebio.output import *
from common.config import torqueConfig as Config

import pandas as pd
from back.web.styleConfig import  tableStyle

def torque_lambdaOptCompareProcess():
    # with use_scope("table_scope", clear=True):
    #     put_table(pd.read_csv(Config.lambdaOptCompareAttr, header=None).values.tolist())
    #     put_html(tableStyle)

    X=pd.read_csv(Config.lambdaOptCompareProcess)
    columns = X.columns
    if len(columns) > 2:
        fig = px.line(X, x=columns[0], y=columns[1], color=columns[2], title='',
                      range_x=[Config.windSpeedFilter_min, Config.windSpeedFilter_max])
    else:
        fig = px.line(X, x=columns[0], y=columns[1], title='',
                      range_x=[Config.windSpeedFilter_min, Config.windSpeedFilter_max])
    fig.update_layout(margin=dict(l=0, r=0, b=0, t=0), height=Config.scatter_3d_height)
    put_html(fig.to_html(include_plotlyjs="require", full_html=False,config={'displayModeBar':False}))

def torque_lambdaCompareProcess():
    # with use_scope("table_scope", clear=True):
    #     put_table(pd.read_csv(Config.lambdaCompareAttr, header=None).values.tolist())
    #     put_html(tableStyle)

    X = pd.read_csv(Config.lambdaCompareProcess)
    columns = X.columns
    if len(columns) > 2:
        fig = px.line(X, x=columns[0], y=columns[1], color=columns[2], title='',
                      range_x=[Config.windSpeedFilter_min, Config.windSpeedFilter_max])
    else:
        fig = px.line(X, x=columns[0], y=columns[1], title='',
                      range_x=[Config.windSpeedFilter_min, Config.windSpeedFilter_max])
    fig.update_layout(margin=dict(l=0, r=0, b=0, t=0), height=Config.scatter_3d_height)
    put_html(fig.to_html(include_plotlyjs="require", full_html=False,config={'displayModeBar':False}))